/**
 * 
 */
package ikelib;

import java.awt.Color;

/**
 * @author ikechan
 *
 */
public class PlotColor {
	
	public static final int COLOR_BW_WHITE_BACK = 0;
	public static final int COLOR_BW_BLACK_BACK = 1;
	public static final int COLOR_COLOR_WHITE_BACK = 2;
	public static final int COLOR_COLOR_BLACK_BACK = 3;
	private ColorTable colorTable = new ColorTable();

	private int ColorMode = COLOR_BW_WHITE_BACK;
	public Color ColorBackGround;
	public Color ColorTimeSample;
	public Color ColorTime1Sec;
	public Color ColorTime1min;
	public Color ColorTime1hour;
	public Color ColorAxis;
	public Color ColorAxisText ;
	public Color ColorXDragging;
	public Color ColorTextInfo;
	public Color ColorCursor;
	public Color ColorDataBW;
	public Color ColorMarker0;
	public Color ColorMarker1;
	public float ColorSaturate;
	
	public float ColorBrightness = (float)0.8;
	private int Brightness = 2;	

	public PlotColor(){
		setColorMode(COLOR_BW_WHITE_BACK);
	}
	
	public int  getColorMode(){
		return ColorMode;
	}
	public void setColorMode(int col){
		if(col==COLOR_BW_WHITE_BACK){
			ColorMode=col;
			ColorBackGround = Color.white;
			ColorTimeSample = Color.orange;
			ColorTime1Sec = Color.blue;
			ColorTime1min = Color.red;
			ColorTime1hour = Color.black;
			ColorAxis = Color.black;
			ColorAxisText = Color.black;
			ColorXDragging = new Color(100,100,100,50);
			ColorTextInfo = Color.black;
			ColorCursor = Color.gray;
			ColorDataBW = Color.gray;
			ColorMarker0 = Color.gray;
			ColorMarker1 = Color.gray;
		}
		else if(col==COLOR_BW_BLACK_BACK){
			ColorMode=col;
			ColorBackGround = Color.black;
			ColorTimeSample = Color.gray;
			ColorTime1Sec = Color.gray;
			ColorTime1min = Color.gray;
			ColorTime1hour = Color.gray;
			ColorAxis = Color.white;
			ColorAxisText = Color.white;
			ColorXDragging = new Color(100,100,100,50);
			ColorTextInfo = Color.white;
			ColorCursor = Color.gray;
			ColorDataBW = Color.white;
			ColorMarker0 = Color.gray;
			ColorMarker1 = Color.gray;
		}
		else if(col==COLOR_COLOR_BLACK_BACK){
			ColorMode=col;
			//ColorSaturate=0.8f;
			ColorBrightness = 1;
			ColorBackGround = Color.BLACK;
			ColorTimeSample = Color.orange;
			ColorTime1Sec = Color.blue;
			ColorTime1min = Color.red;
			ColorTime1hour = Color.black;
			ColorAxis = Color.white;
			ColorAxisText = Color.white;
			ColorXDragging = new Color(200,200,200,50);
			ColorTextInfo = Color.white;
			ColorCursor = Color.orange;
			ColorDataBW = Color.gray;
			ColorMarker0 = Color.red;
			ColorMarker1 = Color.blue;
		}
		else if(col==COLOR_COLOR_WHITE_BACK){
			ColorMode=col;
		//	ColorSaturate=0.8f;
			ColorBrightness = 2;
			ColorBackGround = Color.white;
			ColorTimeSample = Color.orange;
			ColorTime1Sec = Color.blue;
			ColorTime1min = Color.red;
			ColorTime1hour = Color.black;
			ColorAxis = Color.black;
			ColorAxisText = Color.black;
			ColorXDragging = new Color(100,100,100,50);
			ColorTextInfo = Color.black;
			ColorCursor = Color.orange;
			ColorDataBW = Color.gray;
			ColorMarker0 = Color.red;
			ColorMarker1 = Color.blue;
		}
		
	}
	public Color getDataColor(int id){
		switch(ColorMode){
		case COLOR_BW_WHITE_BACK:
			return ColorDataBW;
		case COLOR_BW_BLACK_BACK:
			return ColorDataBW;
		case COLOR_COLOR_BLACK_BACK:
			return calcColor(id);
		case COLOR_COLOR_WHITE_BACK:
			return calcColor(id);
		}
		return ColorDataBW;
	}
	private Color calcColor(int id){
		int seed = id;
		if(seed < 0) seed *= -1;
		int idx = seed % colorTable.getTableSize();
		colorTable.setBrightness(Brightness);
		return colorTable.getColor(idx);
		
	}

}
